import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

// import { h } from 'vue';
import { DictEnum } from '@vben/constants';
// import { VbenIcon } from '@vben/icons';
// import { getPopupContainer } from '@vben/utils';

// import { Tag } from 'ant-design-vue';
// import { z } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'name',
    label: '系列名称',
  },
  {
    component: 'Input',
    fieldName: 'shortName',
    label: '系列简称',
  },
  {
    component: 'Select',
    componentProps: {
      options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
    },
    fieldName: 'status',
    label: '状态',
  },
];

export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: '系列名称',
    field: 'name',
    minWidth: 270,
    slots: { default: 'name' },
  },
  {
    title: '系列简称',
    field: 'shortName',
    width: 150,
  },
  {
    title: '介绍',
    field: 'introduction',
    width: 200,
    visible: false,
  },
  {
    title: '小程序热门主题',
    field: 'isPopular',
    slots: {
      default: ({ row }) => {
        return renderDict(row.isPopular, DictEnum.BUSINESS_YES_NO, true);
      },
    },
    width: 140,
    visible: false,
  },
  {
    title: '排序',
    field: 'sort',
    width: 100,
  },
  {
    title: '状态',
    field: 'status',
    slots: { default: 'status' },
    width: 130,
  },
  {
    title: '备注',
    field: 'remark',
    width: 200,
    visible: false,
  },
  {
    title: '创建时间',
    field: 'createTime',
    width: 180,
    // visible: false,
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 280,
  },
];

export const drawerSchema: FormSchemaGetter = () => [
  {
    label: '主键id',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '系列名称',
    fieldName: 'name',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '系列简称',
    fieldName: 'shortName',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '介绍',
    fieldName: 'introduction',
    component: 'Textarea',
    componentProps: {
      autoSize: { minRows: 5 },
    },
    rules: 'required',
  },
  // {
  //   label: '首页banner',
  //   fieldName: 'imgUrl',
  //   component: 'FileUpload',
  //   rules: 'required',
  // },
  // {
  //   label: '移动端首页banner',
  //   fieldName: 'mobileImgUrl',
  //   component: 'FileUpload',
  //   rules: 'required',
  // },
  // {
  //   label: '缩略图',
  //   fieldName: 'thumbnailUrl',
  //   component: 'FileUpload',
  //   rules: 'required',
  // },
  {
    label: '小程序热门主题',
    fieldName: 'isPopular',
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      options: getDictOptions(DictEnum.BUSINESS_YES_NO, true),
      optionType: 'button',
    },
    defaultValue: 1,
    help: '是否在「易会通」小程序首页的热门主题板块展示',
    rules: 'selectRequired',
  },
  // {
  //   label: '着落页是否展示',
  //   fieldName: 'isLanding',
  //   component: 'Input',
  //   rules: 'required',
  // },
  // {
  //   label: '着陆页主图',
  //   fieldName: 'landingImgUrl',
  //   component: 'Input',
  //   rules: 'required',
  // },
  // {
  //   label: '着陆页亮点',
  //   fieldName: 'landingHighlight',
  //   component: 'Input',
  //   rules: 'required',
  // },
  // {
  //   label: 'banner是否加水印 0 否 1 是',
  //   fieldName: 'hasAddBannerWatermark',
  //   component: 'Input',
  //   rules: 'required',
  // },
  {
    component: 'InputNumber',
    fieldName: 'sort',
    help: '排序, 数字越小越靠前',
    label: '显示排序',
    defaultValue: 0,
    rules: 'required',
  },
  {
    label: '状态',
    fieldName: 'status',
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
      optionType: 'button',
    },
    defaultValue: '0',
    rules: 'selectRequired',
  },
  {
    label: '备注',
    fieldName: 'remark',
    component: 'Textarea',
  },
];

export const detailsSchema: DetailsModalSchemaGetter = () => [
  {
    label: '系列名称',
    fieldName: 'name',
    copy: true,
  },
  {
    label: '系列简称',
    fieldName: 'shortName',
    copy: true,
  },
  {
    label: '介绍',
    fieldName: 'introduction',
    textWrap: true,
    copy: true,
  },
  {
    label: '小程序热门主题',
    fieldName: 'isPopular',
    dictEnum: DictEnum.BUSINESS_YES_NO,
  },
  {
    label: '排序',
    fieldName: 'sort',
  },
  {
    label: '状态',
    fieldName: 'status',
    dictEnum: DictEnum.SYS_NORMAL_DISABLE,
  },
  {
    label: '备注',
    fieldName: 'remark',
    textWrap: true,
  },
];
